#include"tcp.h"

TCPHeader_t *tcp_header;

void init_tcp(FILE *fp){
    tcp_header = (TCPHeader_t *)malloc(sizeof(TCPHeader_t));
    memset(tcp_header, 0, sizeof(TCPHeader_t));
    if (fread(tcp_header, sizeof(TCPHeader_t), 1, fp) != 1)
    {
        printf("can not read tcp_header\n");
    }
}

//源端口
int  get_tcp_src_port(){
    return ntohs(tcp_header->SrcPort);
}

//目的端口
int  get_tcp_des_port(){
    return ntohs(tcp_header->DstPort);
}

void free_tcp(){
    free(tcp_header);
}

void process_tcp(FILE *fp){
    init_tcp(fp);
    printf("src_port:%d\t\t\t des_port:%d\n",get_tcp_src_port(),get_tcp_des_port());
    free_tcp();
}